/*
This is an example script for a 2D polygon graphic. Click the Execute button to apply and then execute this script. Upon each execution the polygon alters its appearance. Turn on animation to execute periodically. Note that typically a polygon graphic should be instantiated on a graph data layer and the graph should be set to autoscale during animation.
*/

/* Declarations */

double cos(double a);
double sin(double a);

@@class() Polygon:Object

@@method(public, class) (id)stored;
@@method(public, instance) (void)emptyData;
@@method(public, instance) (unsigned)animationCount;
@@method(public, instance) (void)appendXValue:(double)xValue yValue:(double)yValue;

@@end

/* Execution block */

{
id myPolygon;
int ii;
double xValue, yValue, radius, center, phase;
unsigned animationCount;

myPolygon = [Polygon stored];

animationCount = [myPolygon animationCount];

/*
Empty the data and then append new data.
*/

[myPolygon emptyData];

center = 4.0;
phase = animationCount * 0.1;

for(ii = 0; ii < 40; ii++)
{

radius = ii * 0.1;

xValue = radius * cos(ii * .3 + phase) + center;
yValue = radius * sin(ii * .3 + phase) + center;

[myPolygon appendXValue:xValue yValue:yValue];
}

}
